package com.MTteam.tool;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;

import android.util.Log;

public class HDK_RSSFeed {
	private String title = null;
	private String pubdate = null;
	private int itemcount = 0;
	private List<HDK_RSSItem> itemlist = new Vector();

	public int addItem(HDK_RSSItem item) {
		itemlist.add(item);
		itemcount++;
		return itemcount;
	}

	public HDK_RSSItem getItem(int location) {
		return itemlist.get(location);
	}

	public List getAllItems() {
		return itemlist;
	}

	public List getAllItemsForListView() {
		Log.e("msg", "item size=" + itemlist.size());
		List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
		int size = itemlist.size();
		for (int i = 0; i < size; i++) {
			HashMap<String, Object> item = new HashMap<String, Object>();
			item.put(HDK_RSSItem.TITLE, itemlist.get(i).getTitle());
			item.put(HDK_RSSItem.PUBDATE, itemlist.get(i).getPubDate());
			item.put(HDK_RSSItem.LINK, itemlist.get(i).getLink());
			item.put(HDK_RSSItem.DESCRIPTION, itemlist.get(i).getDescription());
			item.put(HDK_RSSItem.CATEGORY, itemlist.get(i).getCategory());
			data.add(item);
		}
		return data;
	}

	int getItemCount() {
		return itemcount;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setPubDate(String pubdate) {
		this.pubdate = pubdate;
	}

	public String getTitle() {
		return title;
	}

	public String getPubDate() {
		return pubdate;
	}

}
